package com.spa.application.service.admin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.admin.DouYinCommentDTO;
import com.spa.application.dto.admin.DouYinOauthDTO;
import com.spa.application.query.PageQuery;
import com.spa.application.query.douyin.CommentQuery;
import com.spa.domain.entity.DouYinComment;
import com.spa.domain.entity.DouYinOauth;
import com.spa.domain.service.DouYinCommentService;
import com.spa.domain.service.DouYinOauthService;
import com.spa.infrastructure.mapper.DouYinCommentMapperStruct;
import com.spa.infrastructure.mapper.DouYinOauthMapperStruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class DouYinApplicationService {

    @Autowired
    private DouYinOauthService douYinOauthService;

    @Autowired
    private DouYinCommentService douYinCommentService;

    public PageResult<DouYinOauthDTO> index(PageQuery query) {
        Page<DouYinOauth> page = douYinOauthService.page(query.getCurrent(), query.getSize());
        return DouYinOauthMapperStruct.INSTANCE.entity2Dto4Page(page);
    }

    public PageResult<DouYinCommentDTO> pageDouYinComment(CommentQuery query) {
        Page<DouYinComment> page = douYinCommentService.page(query.getCurrent(), query.getSize(), query.getItemId());
        return DouYinCommentMapperStruct.INSTANCE.entity2Dto4Page(page);
    }

    public PageResult<DouYinCommentDTO> pageSecondaryDouYinComment(CommentQuery query) {
        Page<DouYinComment> page = douYinCommentService.page(query.getCurrent(), query.getSize(), query.getItemId(), query.getCommentId());
        return DouYinCommentMapperStruct.INSTANCE.entity2Dto4Page(page);
    }

}
